function [ feature_val, feature_struct ] = extract_feature_set( data, header, range, parsed_feature_set )
%EXTRACT_FEATURE_SET Summary of this function goes here
%   Detailed explanation goes here

feature_val = [];
feature_struct = {};
last_fid = '';
for i=1:length(parsed_feature_set)
    fstruct = parsed_feature_set{i};
    %if strcmp(fstruct.feature_id, last_fid)
    %    val = last_fval;
    %else
        input_ch = fstruct.input_ch;
        func = ['feature_' fstruct.feature_id '(data, header, range, input_ch)'];
        %if exist(['feature_' fstruct.feature_id], 'file') ~= 2
        %    error(['Feature function ' fstruct.feature_id ' not found']);
        %end
        val = eval(func);
        last_fval = val;
        last_fid = fstruct.feature_id;
    %end
    if fstruct.feature_channel
        feature_val(end+1) = val(fstruct.feature_channel);
        feature_struct{end+1} = fstruct;
    else
        for i=1:length(val)
            tmp_fs = fstruct;
            tmp_fs.feature_channel = i;
            feature_struct{end+1} = tmp_fs;
        end
        feature_val = [feature_val val];
    end
end

end
